Vue.filter('toGender',function(value){
    return value ? '男':'女';
});
new Vue({
    el:'#root',
    data:{
        userData:Mock.mock({
            'data|10':[{
                name:'@cname',
                gender:'@boolean',
                city:'@city',
                phoneNumber:/^1[345789]\d{9}$/,
                age: '@integer(16,30)',
            }]}).data,
        ftBar:['男生','女生','20以下','移动'],
        selectedKey: -1,
        show:true,
    },
    methods:{
        clickToDel(index){
            this.userData.splice(index,1);
        },
        fn(){
            console.log(this.username);
        },
        select(key){
            this.selectedKey = key;
        },
    },
    computed: {
        filterUser: function () {
            let selectedFns = {
                '-1': () => true,
                0: value => value.gender,
                1: value => !value.gender,
                2: value => value.age < 20,
                3: value => /^1[3458]/.test(value.phoneNumber),
            };
            return this.userData.filter(selectedFns[this.selectedKey]);
        },
    }
});
